<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="created" content="2018-10-23T06:18:10.521000000">
    <meta name="changed" content="2020-06-26T10:59:00.126200000">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Language" content="en">
    <title>
      Bit Finder
    </title>
    <link rel="stylesheet" type="text/css" href="../../style.css">
  </head>
  <body>
    <div class="maindiv">
      <h1>
        <img class="iconlibs" src="../../../../icons/6464/bitfindr.png" alt="#########" width="32" height="32" align="middle"> <em>Bit Finder</em>
      </h1>
      <table>
        <tbody>
          <tr>
            <td>
              <strong>Library:</strong>
            </td>
            <td>
              <a href="index.html">Arithmetic</a>
            </td>
          </tr>
          <tr>
            <td>
              <strong>Introduced:</strong>
            </td>
            <td>
              2.6.1
            </td>
          </tr>
          <tr>
            <td valign="top">
              <strong>Appearance:</strong>
            </td>
            <td valign="top">
              <img class="appearancelibs" src="../../../../img-libs/bitfindr.png" alt="#########" width="64" height="64">
            </td>
          </tr>
        </tbody>
      </table>
      <h2>
        Behavior
      </h2>
      <p>
        The component takes a multi-bit input and determines the the index of a bit, where the index is computed by counting from 0 as the lowest-order bit. Exactly which index it computes depends on the Type attribute, as illustrated by the examples in the below table for the 8-bit sample input 11010100.
      </p>
      <blockquote>
        <table>
          <thead>
            <tr>
              <th>
                Type
              </th>
              <th>
                Output for 11010100
              </th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>
                Lowest-order 1
              </td>
              <td align="center">
                2
              </td>
            </tr>
            <tr>
              <td>
                Highest-order 1
              </td>
              <td align="center">
                7
              </td>
            </tr>
            <tr>
              <td>
                Lowest-order 0
              </td>
              <td align="center">
                0
              </td>
            </tr>
            <tr>
              <td>
                Highest-order 0
              </td>
              <td align="center">
                5
              </td>
            </tr>
          </tbody>
        </table>
      </blockquote>
      <p>
        For the lowest-order 1, the output is 2 because if you index the bits starting from 0 for the lowest-order bit, the first 1 you will find is at index 2. (The bits at indices 0 and 1 are both 0.) For the highest-order 1, the output is 7 because the topmost 1 bit is at index 7 (again counting from the lowest-order bit as 0).
      </p>
      <p>
        The component's output on the south edge indicates whether the desired bit was found at all. In the above examples involving the input 11010100, the south output is 1 in all cases. But if the input were 00000000 and the component is to find the lowest-order 1, then the south output would be 0 — and the output on the east edge would be 0 as well.
      </p>
      <p>
        If while searching for the desired value, a value that is neither 0 or 1 is found (the bit could be floating or an error value), then both outputs will consist entirely of error bits. Note that this occurs only if the problematic bit is encountered before finding the desired bit: For the input x1010100, the output would still be 2 if the lowest-order 1 is desired; but we would get error values if the component's type indicates to search for the highest-order 1 or the highest-order 0, since there is an erroneous bit in a higher-order bit than either the highest-order 0 or the highest-order 1.
      </p>
      <h2>
        Pins
      </h2>
      <dl>
        <dt>
          West edge (input, bit width matches Data Bits attribute)
        </dt>
        <dd>
          The multibit input that is to be searched for the desired bit.
        </dd>
        <dt>
          East edge (output, bit width computed as described below)
        </dt>
        <dd>
          The index of the desired bit, counting from 0 for the lowest-order bit. The bit width is the minimum number of bits to store the maximum possible index, which is one less than the value of the Data Bits attribute.
        </dd>
        <dt>
          South edge (output, bit width 1)
        </dt>
        <dd>
          1 if the desired bit is found, 0 if all input bits are the inverse of the desired bit, and the error value if a non-0, non-1 value is found before the desired bit.
        </dd>
      </dl>
      <h2>
        Attributes
      </h2>
      <p>
        When the component is selected or being added, <b class="tkeybd">Alt-0</b> throught <b class="tkeybd">Alt-9</b> alter its <b class="propertie">Data Bits</b> attribute.
      </p>
	  <div class="attliste">
      <dl>
        <dt>
          <b class="propertie">Data Bits</b>
        </dt>
        <dd>
          The bit width of the input.
        </dd>
        <dt>
          <b class="propertie">Type</b>
        </dt>
        <dd>
          Indicates which bit to search for — the lowest-order 0, the highest-order 0, the lowest-order 1, or the highest-order 1.
        </dd>
      </dl>
	  </div>
      <h2>
        Poke Tool Behavior
      </h2>
      <p>
        None.
      </p>
      <h2>
        Text Tool Behavior
      </h2>
      <p>
        None.
      </p>
      <p>
         <b>Back to</b> <a href="../index.html">Library Reference</a>
      </p>
    </div>
  </body>
</html>
